<?php
$uid= $_POST['Uid'];
$scriptid=$_POST['ScriptID'];
$scriptname=$POST['ScriptName'];
$dir = "./".$uid."/".$scriptid."/";
// Open a known directory, and proceed to read its contents
$reply=array();
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
	while (($file = readdir($dh)) !== false) 
	{
		if($file!="."&&$file!=".."){
			if(filetype($dir . $file)=="file")
			{
				$content=file_get_contents($dir.$file);
				array_push($reply, array(
									'dir'=>$scriptid.$scriptname,
									'filename'=>$file,
									'filecontent'=>$content
									)
							);
			}
			else
			{
				$fatherdir=$file;
				$subdir=$dir.$file."/";
				if ($subdh = opendir($subdir)) {
					while (($file = readdir($subdh)) !== false) 
					{
						if($file!="."&&$file!=".."){
							if(filetype($subdir . $file)=="file")
							{
								$content=file_get_contents($subdir.$file);
								array_push($reply, array(
													'dir'=>$scriptid.$scriptname."/".$fatherdir,
													'filename'=>$file,
													'filecontent'=>$content
													)
											);
							}
						}
					}
				}
				closedir($subdh);
			}
			}
		}
	} 
	closedir($dh);
}
echo json_encode($reply);
?>